﻿#ifndef __SS_PROCESSOR_DISPATCH_H__
#define __SS_PROCESSOR_DISPATCH_H__
#include "../ssBaseDefine.h"
#include "../container/hashmap.h"
#include "../container/ssFunction.h"
#include "ssMsgProcessor.h"

namespace StarSeeker
{

#define SS_EVENT_PROCESSOR_MAP(e_id, obj)	{StarSeeker::ssFunc<StarSeeker::ssMsgProcessor::pHandelMessage,StarSeeker::ssMsgProcessor> aFunc(&StarSeeker::ssMsgProcessor::HandelMessage,obj); m_map[e_id] = aFunc;}

class ssProcessorDispatch
{
public:
	ssProcessorDispatch()
	{
		//SS_EVENT_PROCESSOR_MAP_INIT
	}
	virtual ~ssProcessorDispatch()
	{
	}

	void CallProcessor(u32 evnId, ulint param1, ulint param2)
	{
		map_it it = m_map.find(evnId);
		if (it != m_map.end())
		{
			if (it->second.IsClassFunc())
			{
				SS_CLASS_FUNC(it->second)(evnId, param1, param2);
			}
		}
	}

protected:
	typedef HASH_MAP<u32, ssFunc<ssMsgProcessor::pHandelMessage, ssMsgProcessor> >::iterator	map_it;
	HASH_MAP<u32, ssFunc<ssMsgProcessor::pHandelMessage, ssMsgProcessor> >	m_map;
};

}
#endif
